<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
<script>
    function Parent(m){
        this.msg = m;
        this.show = function(){
            console.log(this.msg);
        }
    }
    Parent.prototype.init = function(){
        console.log("init")
    }
    Parent.prototype.say = function(){
        console.log("hi")
    }

    function Child(m){}
    // 注意深浅拷贝
    // Child.prototype = Parent.prototype;

    for(let i in Parent.prototype){
        Child.prototype[i] = Parent.prototype[i];
    }
    // for(let i in Parent2.prototype){
    //     Child.prototype[i] = Parent2.prototype[i];
    // }
    // for(let i in Parent3.prototype){
    //     Child.prototype[i] = Parent3.prototype[i];
    // }

    Child.prototype.say = function(){
        console.log("你好");
    }

    const p = new Parent("hello");
    console.log(p);
    p.show();
    p.init();
    p.say();
    
    const c1 = new Child("world")
    console.log(c1);
    // c1.show();
    c1.init();
    c1.say();

</script>
</html>